package com.infoland.afanmall.model.my.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.model.my.activity.WuLiuInfoActivity;
import com.infoland.afanmall.model.my.adapter.WlAdapter;
import com.infoland.afanmall.my.entity.WlEntity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 物流信息ViewPage
 */
public class WlFragment extends Fragment {
    Unbinder unbinder;
    @BindView(R.id.my_wl_recycl)
    RecyclerView myWlRecycl;
    List<WlEntity> entityList;

    private int getLayout() {
        return R.layout.wu_liu_fragment;
    }

    public void initData() {

        myWlRecycl.setLayoutManager(new LinearLayoutManager(getActivity()));
        WlAdapter wlAdapter = new WlAdapter(R.layout.item_msg_wl, getDatas(), getActivity());
        wlAdapter.setOnItemClickListener((adapter, view, position) -> {
            ToolsKit.go(getContext(), WuLiuInfoActivity.class, null);
        });
        wlAdapter.setOnItemChildClickListener((adapter, view, position) -> {

        });
        myWlRecycl.setAdapter(wlAdapter);
        addLinstener();
    }

    private List getDatas() {
        entityList = new ArrayList<>();
        entityList.add(new WlEntity());
        entityList.add(new WlEntity());
        entityList.add(new WlEntity());
        entityList.add(new WlEntity());
        return entityList;
    }

    private void addLinstener() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(getLayout(), container, false);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
